package com.netease.xone.activity;

import android.app.Activity;
import android.content.Context;
import android.content.Intent;
import android.os.Bundle;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentTransaction;
import android.widget.LinearLayout;

import com.netease.xone.R;
import com.netease.xone.fragment.FragAccountMgr;


public class ActivityAccountMgr extends ActivityX1Base {
    
    public static void launch(Context context){
        Intent intent = new Intent(context, ActivityAccountMgr.class);
        //非activity的context启动activity会出错
        if(!(context instanceof Activity))
            intent.addFlags(Intent.FLAG_ACTIVITY_NEW_TASK);
        context.startActivity(intent);
    }
    
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        LinearLayout linear = new LinearLayout(this);
        linear.setId(R.id.activity_AccountManager_container_id);
        LinearLayout.LayoutParams lp = new LinearLayout.LayoutParams(
                LinearLayout.LayoutParams.MATCH_PARENT,
                LinearLayout.LayoutParams.MATCH_PARENT);
        linear.setLayoutParams(lp);
        setContentView(linear);

        if (findViewById(R.id.activity_AccountManager_container_id) != null
                && savedInstanceState == null) {
            FragmentManager fm = getSupportFragmentManager();
            FragmentTransaction ft = fm.beginTransaction();
            FragAccountMgr fragment = new FragAccountMgr();
            ft.add(R.id.activity_AccountManager_container_id, fragment);
            ft.commit();
        }
    }

}
